﻿#region << 文件说明 >>

/*----------------------------------------------------------------
 * 命名空间：Vampirewal.BlogCore.Controls
 * 唯一标识：2c6bf6a7-81a0-451f-b8cb-b4916fdc1e46
 * 文件名：Row
 *
 * 创建者：杨程
 * 电子邮箱：235160615@qq.com
 * 创建时间：2024/6/25 9:16:52
 * 版本：V1.0.0
 * 描述：
 *
 * ----------------------------------------------------------------
 * 修改人：
 * 时间：
 * 修改说明：
 *
 * 版本：V1.0.1
 *----------------------------------------------------------------*/

#endregion << 文件说明 >>

namespace Vampirewal.BlogCore;

/// <summary>
/// 行
/// </summary>
public sealed class Row : ContainerControlBase
{
    /// <summary>
    /// 构造函数
    /// </summary>
    internal Row()
    {
    }

    public override string Title { get; set; }
    public override List<ControlBase> Children { get; internal set; }
    public override string Id { get; set; }

    public override string ConverToHtml()
    {
        StringBuilder sb = new StringBuilder();

        sb.AppendLine($"<el-row>");

        foreach (var item in Children)
        {
            sb.AppendLine(item.ConverToHtml());
        }

        sb.AppendLine($"</el-row>");

        return sb.ToString();
    }
}

public static partial class App
{
    /// <summary>
    /// 创建行
    /// </summary>
    /// <param name="rowAction"></param>
    /// <returns></returns>
    public static Row CreateRow(Action<List<ControlBase>> rowAction)
    {
        Row row = new Row()
        {
            Id = GenerateId(),
            Title = "row",
            Children = new List<ControlBase>(),
        };

        rowAction.Invoke(row.Children);

        return row;
    }
}